Skip to content

Conversation

@tgauth
Copy link
Collaborator

@tgauth tgauth commented Nov 21, 2025

PR Summary

  • updates sshdconfig Rust parser to support match blocks
  • updates sshdconfig Rust parser to support operator nodes - add (+), remove (-), insert (^)
  • updates sshdconfig Rust parser to distinguish between space-separated and comma-separated multi-arg keywords

PR Context

@tgauth tgauth marked this pull request as draft November 21, 2025 21:31
@tgauth tgauth requested a review from Copilot November 21, 2025 21:49
Copilot finished reviewing on behalf of tgauth November 21, 2025 21:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands the sshdconfig Rust parser to add support for three key features:

  1. Match blocks: Parses SSH match directives with criteria and associated keywords, storing them as nested objects with repeatability support
  2. Operator nodes: Handles the +, -, and ^ operators used to modify keyword values, wrapping them in a structure with separate "operator" and "value" fields
  3. Keyword separation types: Distinguishes between comma-separated and space-separated multi-argument keywords for correct parsing

The changes improve the parser's ability to handle complex SSH server configurations, particularly conditional settings via match blocks and list modifications via operators.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
resources/sshdconfig/src/parser.rs Main parser logic updated to handle match blocks, operators, and different keyword separation types; adds new KeywordType enum and refactors parsing functions for reusability
resources/sshdconfig/src/metadata.rs Splits MULTI_ARG_KEYWORDS into separate MULTI_ARG_KEYWORDS_COMMA_SEP and MULTI_ARG_KEYWORDS_SPACE_SEP constants to distinguish separation types
resources/sshdconfig/locales/en-us.toml Adds new error messages for match block parsing (missingCriteriaInMatch, noArgumentsFound)
grammars/tree-sitter-ssh-server-config/grammar.js Changes _quotedString to quotedString (removes underscore prefix) to make it a named node in the parse tree
grammars/tree-sitter-ssh-server-config/test/corpus/valid_expressions.txt Updates test expectations to reflect quotedString as a named node instead of inline string
Comments suppressed due to low confidence (1)

resources/sshdconfig/src/parser.rs:251

  • This error case is unreachable. Since map.contains_key(key) was checked on line 234, map.get_mut(key) on line 236 will always return Some(...), never None. Consider simplifying this code by removing the else branch or using .unwrap() with a comment explaining why it's safe.
                } else {
                    return Err(SshdConfigError::ParserError(t!("parser.keyNotFound", key = key).to_string()));
                }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant